import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import {viteMockServe} from 'vite-plugin-mock'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vite.dev/config/
export default defineConfig(({command})=>{
  return {
    plugins: [
      vue(),
      vueJsx(),
      vueDevTools(),
      viteMockServe({
        mockPath: 'mock',
        enable: true,
      }),
      AutoImport({
        // 自动导入 Vue 相关函数，如：ref, reactive, toRef 等
        imports: ['vue', 'vue-router'],
        // 自动导入 Element Plus 相关函数
        resolvers: [ElementPlusResolver()],
        // 生成自动导入的TS声明文件
        dts: 'src/types/auto-imports.d.ts',
        // 设置为 true 时会在项目根目录生成 .eslintrc-auto-import.json 文件
        // eslintrc: {
        //   enabled: true, // 默认 false
        //   filepath: './.eslintrc-auto-import.json', // 默认 './.eslintrc-auto-import.json'
        //   globalsPropValue: true, // 默认 true (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
        // },
      }),
     Components({
        resolvers: [ElementPlusResolver()],
        dts: 'src/types/components.d.ts',
      }),


    ],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      },
    },
  }
})
